<extend name="public:base" />

<block name="left">
	<div class="mark_bar cl">
		<a href="{:url('user/index/index')}" class="goback fl"><i class="iconfont">&#xe600;</i></a>
		<p>邀请有礼</p>
		<a href="{:url('user/promote/reward')}" class="btm">旧版邀请奖励</a>
	</div>
</block>

<block name="main">
	<div class="container">

		<div class="promotion-header">
			<div class="money">
				<em>{$total_paid|default=''}</em>
				<p>累计获得邀请奖励(元）</p>
			</div>
			<a href="{:url('user/promote/detail',['status'=>1])}" class="rewardBtn">奖励详情</a>
		</div>
		<a href="{:url('uc/promote/friends')}" class="promotion-friend cl">
			<span class="txt fl">邀请好友数</span>
			<i class="iconfont fr small a999">&#xe611;</i>

				<span class="txt fr small af60">{$friend_count|default=''}位好友</span>

				<span class="txt fr small a999">暂无好友应邀，试试发个邀请吧</span>

		</a>
		<ul class="promotion-rules">
			<li>
				<a href="{:url('index/activity/recommend')}">
					<i class="icon"><img src="__IMG__/ucpromote/friend.jpg" /></i>
					<p>邀请规则</p>
				</a>
			</li>
			<li>
				<a href="{:url('uc/promotion/card')}">
					<i class="icon"><img src="__IMG__/ucpromote/redpacker.jpg" /></i>
					<p>发红包</p>
				</a>
			</li>
		</ul>
		<div class="recommend_ways">
			<a href="javascript:openShare()" class="submit promotion-now">立即邀请</a>
			<a href="javascript:openPoster()" class="erweima"><i>二维码邀请</i></a>
		</div>

		<div class="recommend_newBox">
			<div class="background" onclick="closeShare()"></div>
			<div class="insetBox">
				<ul>
					<li>
						<a href="javascript:void(0);" onclick="onShare('sina')">
							<span class="image"><img src="__IMG__/ucpromote/icon2.png" width="100%" /></span>
							<p class="txt">新浪微博</p>
						</a>
					</li>
					<li>
						<a href="javascript:void(0);" onclick="onShare('qzone')">
							<span class="image"><img src="__IMG__/ucpromote/icon4.png" width="100%" /></span>
							<p class="txt">QQ空间</p>
						</a>
					</li>
					<li>
						<a href="javascript:void(0)" onclick="layer_remo();">
							<span class="image"><img src="__IMG__/ucpromote/icon5.png" width="100%" /></span>
							<p class="txt">推荐码</p>
						</a>
					</li>
					<li>
						<button class="copybtn">&nbsp;</button>
						<span class="image"><img src="__IMG__/ucpromote/icon6.png" width="100%" /></span>
						<p class="txt">复制链接</p>
					</li>
					<div class="cl"></div>
				</ul>
			</div>
		</div>
		<div class="share-box">
			<img src="__PUBLIC__/activity/recommend/share/m_share.png" />
		</div>
		<div class="posterBox">
			<a href="javascript:closePoster()" class="closeBtn"><i class="iconfont">&#xe602;</i></a>
			<img src="__QRCODE__/{$data.wx_url|default=''}" class="erCodeImg" />
		</div>
	</div>

</block>

<block name="menu"></block>

<block name="js">
	<style>
		body{background: #fff;}
		.share-box{ display:none; width:100%; height:100%; background:rgba(0,0,0,0.75); position:fixed; top:0; left:0; z-index:99;}
		.share-box img{width:80%; display: block; margin-top:1.5rem; margin-left:12%;}
		.posterBox{ display: none; width: 100%; height: 100%; position: fixed; left: 0; top: 0; z-index: 200; background: url("__IMG__/ucpromote/poster.png") no-repeat; background-size: 20rem;}
		.posterBox .closeBtn{width: 3rem; height: 3rem; position: absolute; top: 0; right: 0; text-align: center; background: rgba(0,0,0,0.6); border-radius:0 0 0 3rem;}
		.posterBox .closeBtn i{color: rgba(255,255,255,0.75); line-height: 2.4rem; padding-left: 0.4rem;}
		.posterBox .erCodeImg{ width: 7.5rem; height: 7.5rem; position: absolute; top: 13.85rem; left: 6.25rem;}
	</style>
	<script type="text/javascript" src="__PUBLIC__/js/clipboard/clipboard.min.js"></script>
	<script type="text/javascript">
        function isWeiXin() {
            var ua = window.navigator.userAgent.toLowerCase();
            if(ua.match(/MicroMessenger/i) == 'micromessenger') {
                return true;
            } else {
                return false;
            }
        }

        var poster = ".posterBox";
        function closePoster() {
			$(poster).fadeOut("fast");
        }
        function openPoster() {
            $(poster).fadeIn("fast");
        }

		/* 分享 */
		var title = encodeURIComponent("我在微金在线投资，预期年化收益率最高15%，推荐你来领好礼！");
		var des = "微金在线（weijinzaixian.com），上市系互联网金融平台，靠谱！50元起投，期限灵活，现在注册就送518元现金红包，赶快来体验吧！";
		var link = encodeURIComponent("{$data.url|default=''}");
		var image = encodeURIComponent('__PUBLIC__/images/recommend_img.jpg');
		
		function onShare(type) {
			if(type == "qzone") {
				window.open("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=" + link + "&title=" + title + "&pics=" + image + "&summary=" + des);
			}
			if(type == "sina") {
				window.open("http://v.t.sina.com.cn/share/share.php?appkey=1252112689&url=" + link + "&title=" + title + "&content=utf8&pic=" + image);
			}
			if(type == "qq") {
				window.open("http://connect.qq.com/widget/shareqq/index.html?url=" + link + "&title=" + title + "&content=utf8&summary=" + des + "&pics=" + image);
			}
			return false;
		}
		
		function layer_remo() {
			layer.open({
				closebtn:true,
				content: '您的手机号即是您的推荐码,请您邀请的好友在注册时,在"推荐人手机号码"一栏输入您已认证的手机号码：<span style="color:#f60;">{$data.phone|default=\'\'}</span>'
			})
		}

		function openShare() {
		    if(isWeiXin()){
                $(".share-box").fadeIn("fast");
                return false;
			}
		    var box = $(".recommend_newBox");
		    box.find(".insetBox").animate({"bottom":0});
            box.fadeIn('fast');
        }

        function closeShare() {
            var box = $(".recommend_newBox");
            box.find(".insetBox").animate({"bottom":'-100%'});
            box.fadeOut('fast');
        }
		
		$(function(){
			// 复制
			var clipboard = new Clipboard('.copybtn', {
				text: function() {
					return '{$data.url|default=''}';
				}
			});
			clipboard.on('success', function(e) {
				layer.open({
					closebtn:true,
					content: '<p style="color:#f60; text-align:center; font-size:16px;">恭喜您,链接复制成功<p>' + '<p>您可以通过微信、QQ、短信等方式将邀请链接发送给好友</p>'
				});
			});
		})
	</script>

	<!--微信分享-->
	<script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	<script type="text/javascript">

        // 微信分享提示关闭
        $(".share-box").click(function() {
            $(this).fadeOut("fast");
        });
        wx.config({
            debug: false,
            appId: '{$wechat.appId|default=\'\'}',
            timestamp: '{$wechat.timestamp|default=\'\'}',
            nonceStr: '{$wechat.nonceStr|default=\'\'}',
            signature: '{$wechat.signature|default=\'\'}',
            jsApiList: [
                // 所有要调用的 API 都要加到这个列表中
                'checkJsApi',
                'onMenuShareTimeline',
                'onMenuShareAppMessage'
            ]
        });

        var obj = {
            title: '【微金在线】您的好友送您518元现金红包，点击领取',
            desc: '我在微金在线投资，过往年化收益最高可达15%，推荐你来领好礼！',
            link: '{$data.url|default=\'\'}',
            imgUrl: '__PUBLIC__/images/recommend_img.jpg'
        };

        wx.ready(function() {
            wx.onMenuShareAppMessage(obj);
            wx.onMenuShareTimeline(obj);
        });
	</script>
</block>